<?php
//发表留言数据
require("db_conn.php");

//判断是否有表单提交
if(!empty($_POST)){
	//获取用户的留言信息
	$username=$_POST['username'];
	$message=$_POST['message'];
	$sex=$_POST['sex'];
	$imgurl=$_POST['imgurl'];
	$sql="insert into t_message(username,message,sex,imgurl)  values('$username','$message','$sex','$imgurl')";
	$rs=$mysqli->query($sql);
	if ($rs)
		{
		  // header("Location:getbbs.php");
		   echo "<script language='javascript' type='text/javascript'>";
		   echo "alert('留言成功');";
		   echo "window.location.href='index.php';";
		   echo "</script>";
		   exit;
		}
	else
		{
		   echo "留言失败！";
		   exit;
		}
	}
else
{
	header("Location:index.php");
}
